<template>
	<view class="store-item">
		<image class="thumb" :src="store.logo" mode="aspectFit"></image>
		<view class="info" @click="pageRoute('/pages/merchant/supermarket/index?store_id='+store.id)">
			<view class="title">
				<text class="name">{{store.name}}</text>
				<view class="distance">
					<uni-icons type="location" color="#909399"></uni-icons>
					<text class="label">距{{store.distance}}km</text>
				</view>
			</view>
			<view class="address">{{store.formatAddress}}</view>
			<view class="other">
				<text class="time">营业时间 {{store.business_hours}}</text>
				<text class="sale-num">销量 {{store.sales_sum}} 份</text>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		defineProps
	} from 'vue';
	const props = defineProps({
		store: {
			type: Object,
			default: () => { //定义默认值
				return []
			}
		},
	})

	function pageRoute(url) {
		uni.navigateTo({
			url
		});
	};
</script>

<style lang="scss">
	.store-item {
		@include f-between;
		padding: $margin-24;
		border-bottom: 2rpx solid mix($white-color, $border-color, 40%);

		&:last-child {
			border-bottom: none;
		}

		.thumb {
			width: 128rpx;
			height: 128rpx;
			background-color: $bg-color;
			border-radius: $radius-8;
		}

		.info {
			flex: 1;
			margin-left: $margin-24;

			.title {
				@include f-between;

				.name {
					@include ellipsis;
					flex: 1;
					font-size: $font-30;
					color: $main-color;
					font-weight: 500;
				}

				.distance {
					@include f-center;
					font-size: $font-22;
					color: $tips-color;
				}
			}

			.address {
				@include ellipsis;
				margin-top: $margin-8;
				font-size: $font-24;
				color: $tips-color;
			}

			.other {
				@include f-between;
				margin-top: $margin-20;

				.time,
				.sale-num {
					font-size: $font-24;
					color: $tips-color;
				}
			}
		}
	}
</style>